import { createMemo, splitProps, type ParentComponent } from "solid-js";
import type { FcFormProps } from "./types";
import { Form } from "solid-form-context";
import { wrapClasses } from "@lib/types";

const FcForm: ParentComponent<FcFormProps> = (props) => {
  const [local, formProps] = splitProps(props, ["children", "classList"]);

  const classList = createMemo(() => wrapClasses(local.classList));

  return (
    <form classList={classList()}>
      <Form {...formProps}>{local.children}</Form>
    </form>
  );
};

export default FcForm;
export * from "./types";
